
package com.thor.palmmall.rest.hdmall.sales.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.hdmall.sales.HDMSalesTotalData;
import com.thor.palmmall.rest.hdmall.sales.MSalesTotalData;

/**
 * @author:liyang
 * @time:2017年7月25日 下午4:14:57
 * @since:1.0
 */
public class MSalesTotalDataConverter implements Converter<HDMSalesTotalData, MSalesTotalData> {

  public static MSalesTotalDataConverter getInstance() {
    if (instance == null)
      instance = new MSalesTotalDataConverter();
    return instance;
  }

  private static MSalesTotalDataConverter instance;

  private MSalesTotalDataConverter() {
  }

  @Override
  public MSalesTotalData convert(HDMSalesTotalData source) {
    if (source == null) {
      return null;
    }
    MSalesTotalData target = new MSalesTotalData();
    target.setDate(source.getDate());
    target.setTotal(source.getTotal());
    target.setDetails(
        ConverterUtil.convert(source.getDetails(), MSalesInputLineConverter.getInstance()));
    return target;
  }

}
